

Ext.define('Holo.store.AppTrips', {
    extend: 'Ext.data.Store',
    requires: 'Holo.model.AppTrip',
    model: 'Holo.model.AppTrip',
    
    
    /**
     *  Remove the trip not selected anymore
     */
    removeOldInstance : function(arrayTripIdSelected){
        
        var tabTripSelected = arrayTripIdSelected;
        var fn = function(relationTripApp){
            var inSelectedTripTab = false;    
            for (var i=0; i < tabTripSelected.length; i++) {
		if(relationTripApp.get('trip_id') == tabTripSelected[i]){
                    inSelectedTripTab = true;
                    break;
		}
	    }
            
            if(! inSelectedTripTab){
                //console.log('removing :' + relationTripApp.get('id'));
                this.remove(relationTripApp);
            }
        }
        
        this.each(fn, this) ;
    },
    
    arrayOfid : function(){
        var tabTripId=[]
        var order, index;
           
        for (var i=0; i < this.count(); i++) {
           order = i + 1;
           index = this.findExact('list_order', order);
           tabTripId.push(this.getAt(index).get('trip_id'));
        }
        return tabTripId;
        
    }
    
    
});